1. Field of the Invention
This invention relates generally to computer generated images and more particularly to a method for computing the intensity of specularly reflected light.
2. Description of the Background Art
The illumination of a computer-generated object by colored light sources and ambient light is described by an illumination model. The illumination model is a mathematical expression including ambient, diffuse, and specular illumination terms. The object is illuminated by the reflection of ambient light and the reflection of light source light from the surface of the object. Therefore, the illumination of the object is composed of ambient, diffuse, and specularly reflected light. Given ambient light and light sources positioned about the object, the illumination model defines the reflection properties of the object. The illumination model is considered to be accurate if the illuminated object appears realistic to an observer. Typically, the illumination model is incorporated in a program executed by a rendering engine, a vector processing unit, or a central processing unit (CPU). The program must be capable of computing the illumination of the object when the light sources change position with respect to the object, or when the observer views the illuminated object from a different angle, or when the object is rotated. Furthermore, an efficient illumination model is needed for the program to compute the illumination in real-time, for example, if the object is rotating. Therefore, it is desired to incorporate terms in the illumination model that are computationally cost effective, while at the same time generating an image of the illuminated object that is aesthetically pleasing to the observer.
Ambient light is generalized lighting not attributable to direct light rays from a specific light source. In the physical world, for example, ambient light is generated in a room by multiple reflections of overhead florescent light by the walls and objects in the room, providing an omni-directional distribution of light. The illumination of the object by ambient light is a function of the color of the ambient light and the reflection properties of the object.
The illumination of the object by diffuse and specular light depends upon the colors of the light sources, positions of the light sources, the reflection properties of the object, the orientation of the object, and the position of the observer. Source light is reflected diffusely from a point on the object""s surface when the surface is rough, scattering light in all directions. Typically, the surface is considered rough when the scale length of the surface roughness is approximately the same or greater than the wavelength of the source light. FIG. 1A illustrates diffuse reflection from an object""s surface. A light ray i 105 from a source 110 is incident upon a surface 115 at point P 120, where a bold character denotes a vector. Light ray i 105 is scattered diffusely about point P 120 into a plurality of light rays r1 125, r2 125, r3 125, r4 125, and r5 125.
If the scale length of the surface roughness is much less than the wavelength of the source light, then the surface is considered smooth, and light is specularly reflected. Specularly reflected light is not scattered omni-directionally about a point on the object""s surface, but instead is reflected in a preferred direction. FIG. 1B illustrates specular reflection from an object""s surface. A light ray i 130 from a source 135 is incident upon a surface 140 at a point P 145. Light ray i 130 is specularly reflected about point P 145 into a plurality of light rays r1 150, r2 150, r3 150, r4 150, and r 155, confined within a cone 160 subtended by angle xcfx86 165. Light ray r 155 is the preferred direction for specular reflection. That is, the intensity of specularly reflected light has a maximum along light ray r 155. As discussed further below in conjunction with FIGS. 2A-2B, the direction of preferred light ray r 155 is specified when the angle of reflection is equal to the angle of incidence.
Typically, objects reflect light diffusely and specularly, and in order to generate a realistic illumination of the computer-generated object that closely resembles the real physical object, both diffuse and specular reflections need to be considered.
FIG. 2A illustrates specular reflection from an object""s surface in a preferred direction, including a unit vector l 205 pointing towards a light source 210, a unit vector n 215 normal to a surface 220 at a point of reflection P 225, a unit vector r 230 pointing in the preferred reflected light direction, a unit vector v 235 pointing towards an observer 240, an angle of incidence xcex8i 245 subtended by the unit vector l 205 and the unit vector n 215, an angle of reflection xcex8r 250 subtended by unit vector n 215 and the unit vector r 230, and an angle xcex8rv 255 subtended by unit vector r 230 and unit vector v 235. Light from the source 210 propagates in the direction of a unit vector xe2x88x92l 260, and is specularly reflected from the surface 220 at point P 225. A unit vector is a vector of unit magnitude.
Reflection of light from a perfectly smooth surface obeys Snell""s law. Snell""s law states that the angle of incidence xcex8i 245 is equal to the angle of reflection xcex8r 250. If surface 220 is a perfectly smooth surface, light from source 210 directed along the unit vector xe2x88x92l 260 at an angle of incidence xcex8i 245 is reflected at point P 225 along unit vector r 230 at an angle of reflection xcex8r 250, where xcex8i=xcex8r. Consequently, if surface 220 is a perfectly smooth surface, then light directed along xe2x88x92l 260 from source 210 and specularly reflected at point P 225 would not be detected by observer 240, since specularly reflected light is directed only along unit vector r 230. However, a surface is never perfectly smooth, and light directed along xe2x88x92l 260 from source 210 and specularly reflected at point P 225 has a distribution about unit vector r 230, where unit vector r 230 points in the preferred direction of specularly reflected light. The preferred direction is specified by equating the angle of incidence xcex8i 245 with the angle of reflection xcex8r 250. In other words, specular reflection intensity as measured by observer 240 is a function of angle xcex8rv 255, having a maximum reflection intensity when xcex8rv=0 and decreasing as xcex8rv 255 increases. That is, observer 240 viewing point P 225 of the surface 220 detects a maximum in the specular reflection intensity when unit vector v 235 is co-linear with unit vector r 230, but as observer 240 changes position and angle xcex8rv 235 increases, observer 240 detects decreasing specular reflection intensities.
A first prior art method for computing the intensity of specularly reflected light is to represent the specular intensity as f(r,v,n)xe2x88x9d(rxc2x7v)n, where 1xe2x89xa6nxe2x89xa6∞ and n is a parameter that describes the shininess of the object. Since r and v are unit vectors, the dot product rxc2x7v=cos xcex8rv, and therefore, f(r,v,n)xe2x88x9d cosnxcex8rv.
A second prior art method computes the intensity of specularly reflected light in an alternate manner. For example, FIG. 2B illustrates another embodiment of specular reflection from an object""s surface in a preferred direction, including a unit vector l 265 pointing towards a light source 270, a unit vector n 275 normal to a surface 280 at a point of reflection P 282, a unit vector r 284 pointing in the preferred reflected light direction, a unit vector v 286 pointing towards an observer 288, a unit vector h 290 bisecting the angle subtended by the unit vector l 265 and the unit vector v 286, an angle of incidence xcex8i 294, an angle of reflection xcex8r 290, and an angle xcex8nh 292 subtended by the unit vector h 290 and the unit vector n 275. Light from the source 270 propagates in the direction of a unit vector xe2x88x92l 272. The angle of incidence xcex8i 294 is equal to the angle of reflection xcex8r 290. The specular intensity is represented as g(n,h,n)xe2x88x9d(nxc2x7h)n, where 1xe2x89xa6nxe2x89xa6∞ and n is a parameter that describes the shininess of the object. Since n and h are unit vectors, the dot product nxc2x7h=cos xcex8nh, and therefore, g(n,h,n)xe2x88x9d cosn xcex8nh. When the surface 280 is rotated such that unit vector n 275 is co-linear with unit vector h 290, then cos xcex8nh=1, the specular intensity g(n,h,n) is at a maximum, and therefore the observer 288 detects a maximum in the specularly reflected light intensity. The second prior art method for computing the intensity of specular reflection has an advantage over the first prior art method in that the second prior art method more closely agrees with empirical specular reflection data.
The first and second prior art methods for computing the intensity of specularly reflected light are computationally expensive compared to the calculation of the diffuse and ambient terms that make up the remainder of the illumination model. Specular intensity as defined by the prior art is proportional to cosn xcex8, where xcex8xe2x89xa1xcex8rv or xcex8xe2x89xa1xcex8nh. The exponential specular intensity function cosn xcex8 can be evaluated for integer n, using nxe2x88x921 repeated multiplications, but this is impractical since a typical value of n can easily exceed 100. If the exponent n is equal to a power of two, for example n=2m, then the specular intensity may be calculated by m successive squarings. However, the evaluation of specular intensity is still cost prohibitive. If n is not an integer, then the exponential and logarithm functions can be used, by evaluating cosnxcex8 as e(n ln(cos xcex8)), but exponentiation is at least an order of magnitude slower than the operations required to compute the ambient and diffuse illumination terms.
A third prior art method of computing specular intensity is to replace the exponential specular intensity function with an alternate formula that invokes a similar visual impression of an illuminated object, however without exponentiation. Specular intensity is modeled by an algebraic function h(t,n)=t/(nxe2x88x92nt+t), where either t=cos xcex8rv or t=cos xcex8nh, and n is a parameter that describes the shininess of the object. The algebraic function h(t,n) does not include exponents, but does include multiplication, addition, subtraction, and division operators. These algebraic operations are usually less costly than exponentiation. However, while the computation time has been reduced, in many computer architectures division is still the slowest of these operations.
It would be useful to implement a cost effective method of calculating specular intensity that puts the computation of the specular term on a more even footing with the computation of the ambient and diffuse terms, while providing a model of specular reflection that is aesthetically pleasing to the observer.
In accordance with the present invention, an algebraic method is disclosed to compute the intensity of specularly reflected light from an object illuminated by a plurality of light sources. The plurality of light sources include point light sources and extended light sources. The algebraic expression Si(n,hi,n)=1xe2x88x92n+max{nxc2x7(nhi), nxe2x88x921} represents the intensity of light reflected from a point on the object as measured by an observer, the object illuminated by an ith light source. The algebraic expression includes multiplication, addition, and subtraction operators. The algebraic expression approximates the results of prior art models of specular reflection intensity, but at lower computational costs.
The algebraic expression for specular intensity is substituted into an illumination model, where the illumination model includes ambient, diffuse, and specular illumination terms. The illumination model is incorporated into a software program, where the program computes a color vector c representing the color and intensity of light reflected by an object illuminated by a plurality of light sources. The reflected light is composed of ambient, diffuse, and specular components. The specular terms in the illumination model are equivalent in functional form to the diffuse terms, thereby providing an efficient and inexpensive means of computing the specular component of the color vector c. That is, a vector-based hardware system that computes and sums the ambient and diffuse terms can be used to compute and sum the ambient, diffuse, and specular terms at very little additional cost.
A modified algebraic expression SMi,k(n,hi,n)=(1xe2x88x92n/k+max{nxc2x7(n/k hi), n/kxe2x88x921})k represents the intensity of light reflected from a point on the object, where the object is illuminated by the ith light source, and 2xe2x89xa6kxe2x89xa6n. The first (kxe2x88x921) derivatives of the modified algebraic expression SMi,k(n,hi,n) are continuous, and therefore by increasing the value of k, the modified algebraic expression more closely approximates the prior art specular intensity functions, but at a lower computational cost.